<template>
  <el-cascader
    :value="value"
    :options="options"
    :props="{label:'name',value:'id'}"
    separator="—"
    size="mini"
    @change="$emit('input',$event[$event.length - 1])"
  />
</template>

<script>
import { getDepartmentAPI } from '@/api/department'
import convertToTree from '@/utils/data-conversion'
export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      options: []
    }
  },
  async created() {
    const result = await getDepartmentAPI() // 获取部门列表
    this.options = convertToTree(result.data)
    console.log('this.options  --->', this.options)
  }
}
</script>

<style>

</style>
